package com.hazardSoft.eStore.integration;

import java.util.List;

import com.hazardSoft.eStore.common.exception.SystemException;
import com.hazardSoft.eStore.common.integration.EJB3ServiceLocator;
import com.hazardSoft.eStore.ejb.OfficesEJB;
import com.hazardSoft.eStore.entities.Office;
import com.hazardSoft.eStore.interfaces.OfficesLocal;
import com.hazardSoft.eStore.utils.PathConstants;

public class OfficesDelegate {

	private static final String CLASS_NAME = PathConstants.DELEGATES_PATH+OfficesDelegate.class.getSimpleName();
	private OfficesLocal officesLocal;
	
	public OfficesDelegate() throws SystemException{
	
		try {
			officesLocal = (OfficesLocal) EJB3ServiceLocator.getLocalEJB(OfficesEJB.EJB_NAME);
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "OfficesDelegate");
		}
	}
	
	public Office insertOffice(Office office) throws SystemException {
		
		try {
			return officesLocal.insertOffice(office);
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "insertOffice");
		}
	}

	
	public List<Office> listOffices() throws SystemException {
		
		try {
			return officesLocal.listOffices();
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "listOffices");
		}
	}

	
	public boolean removeOffice(Office office) throws SystemException {
		
		try {
			return officesLocal.removeOffice(office);
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "removeOffice");
		}
	}

	
	public Office searchOfficeById(Office office) throws SystemException {
		
		try {
			return officesLocal.searchOfficeById(office);
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "searchOfficeById");
		}
	}

	
	public Office searchOfficeByName(Office office) throws SystemException {
		
		try {
			return officesLocal.searchOfficeByName(office);
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "searchOfficeByName");
		}
	}

	
	public Office updateOffice(Office office) throws SystemException {
		
		try {
			return officesLocal.updateOffice(office);
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "updateOffice");
		}
	}

}
